//
//  TextView.swift
//  WBDemo
//
//  Created by Meng on 17/2/27.
//  Copyright © 2017年 demo. All rights reserved.
//

import UIKit

class TextView: XMGKeyboardTextView {

    override init(frame: CGRect, textContainer: NSTextContainer?) {
        super.init(frame: frame, textContainer: textContainer)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setupUI()
    }
    private func setupUI() {
        addSubview(placehodeler)
        
        placehodeler.snp.makeConstraints { (ConstraintMaker) in
            ConstraintMaker.left.equalTo(4)
            ConstraintMaker.top.equalTo(8)
        }
        NotificationCenter.default.addObserver(self, selector: #selector(textChange), name: NSNotification.Name.UITextViewTextDidChange, object: nil)
    }
    
    private lazy var placehodeler: UILabel = {
        let label = UILabel()
        label.text = "分享新鲜事..."
        label.font = self.font
        label.textColor = UIColor.lightGray
        return label
    }()
    
    @objc func textChange() {
        placehodeler.isHidden = hasText
    }
}
